﻿using System.Linq;
using System.Reflection;
using System.Web.Mvc;

namespace NewsPortal.Web.Infrastructure.Modularity.ModuleControllerFactory
{

    public class ControllerActionFactory : IControllerActionFactory
    {
        public MethodInfo CreateAction(Controller controller, string actionName)
        {
            return controller.GetType()
                .GetMethods()
                    .Where(m => m.Name == actionName && m.ReturnType == typeof(ActionResult))
                        .First();
        }
    }
}